eval((()=>{
	if (!GM_getValue('viocha-gm-util')){
		fetchGmUtilScript().then(()=>location.reload());
		return '';
	}
	console.log(`=================== gm-util loaded from ${GM.info.script.name} =======================`);
	
	setTimeout(fetchGmUtilScript, 5000); // 5秒之后更新脚本内容
	return GM_getValue('viocha-gm-util'); // 不能使用window.eval，它是与unsafeWindow交互的
	
	async function fetchGmUtilScript(){
		const script = await new Promise((resolve, reject)=>{
			GM_xmlhttpRequest({
				url:'https://gitee.com/viocha/gm-util/raw/main/dist/gm-util.js',
				responseType:'text',
				onload:resp=>resolve(resp.responseText),
				onerror:()=>reject('请求错误'),
			});
		});
		GM_setValue('viocha-gm-util', script);
	}
})());
// 将gmutil的所有方法挂载到GM的window上
Object.assign(window, window.gmutil);
